package chan.com.huishang.ui.adpters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import chan.com.huishang.R;
import chan.com.huishang.beans.ItemBean;

/**
 * Created by chen on 2017/12/27.
 */
public class StudyGridViewadpter extends BaseAdapter {

    Context context;

    public StudyGridViewadpter(List<ItemBean> topBeen, Context context) {
        this.topBeen = topBeen;
        this.context = context;
    }

    private List<ItemBean> topBeen;

    @Override
    public int getCount() {
        return topBeen.size();
    }

    @Override
    public ItemBean getItem(int position) {
        return topBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_griwd_view_top, null);
            viewHolder = new ViewHolder();
            viewHolder.tv_desc = (TextView) convertView.findViewById(R.id.desc);
            viewHolder.iv_icons = (ImageView) convertView.findViewById(R.id.iv_icons);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.iv_icons.setImageResource(topBeen.get(position).getRes_Id());
        viewHolder.tv_desc.setText(topBeen.get(position).getmDesccrit());
        return convertView;
    }

    public static class ViewHolder {
        private TextView tv_desc;
        private ImageView iv_icons;
    }
}
